package com._520it._05_cache;

import com._520it.util.MybatisUtil;
import org.apache.ibatis.session.SqlSession;
import org.junit.Test;

public class CacheTest {




	@Test
	public void testSave() throws Exception {

		SqlSession session = MybatisUtil.getSession();
		StudentMapper mapper = session.getMapper(StudentMapper.class);
		Student student = new Student(null,"张明",15,"天河区");

		mapper.save(student);
		session.commit();
		session.close();
	}




	@Test
	public void testGet() throws Exception {
		
		SqlSession session = MybatisUtil.getSession();
		StudentMapper mapper = session.getMapper(StudentMapper.class);
		Student student = mapper.get(2L);
         System.out.println(student);
        
         Thread.sleep(4000);


         //下面的SQL使用的是: Cache Hit Ratio [com._520it._05_cache.StudentMapper]: 0.0
         Student student1 = mapper.get(2L);
         System.out.println(student1);
         
		session.commit();
		session.close();
		
		
	}
	
	
}
